package com.abc.mapper;


import com.abc.bean.Doctor;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:34
 * @Description:
 */
public interface DoctorMapper {
    @Select("<script>" +
        "select " +
            "id,doctor_id as doctorId, " +
            "doctor_name as doctorName,doctor_age as doctorAge, " +
            "doctor_gender as doctorGender,doctor_job as doctorJob " +
            "from doctor" +
        "<where>" +
        "<if test='doctorName!=null and doctorName!=\"\"'>" +
        "and doctor_name like concat('%',#{doctorName},'%')" +
        "</if>" +
        "</where>"+
        "</script>")
    List<Doctor> selectDoctor(@Param("doctorName") String doctorName);

    @Select("select  id, doctor_name as doctorName from doctor")
    List<Doctor> selectAllDoctor();

    @Select("select * from doctor where doctor_id=#{doctorId}")
    Doctor selectOneDoctorByDoctorId(String doctorId);

    @Insert("insert into doctor(doctor_id,doctor_name,doctor_age,doctor_gender,doctor_job) values (#{doctorId},#{doctorName},#{doctorAge},#{doctorGender},#{doctorJob})")
    int addDoctor(Doctor doctor);

    @Delete("delete from doctor where id=#{id}")
    int deleteDoctor(String id);

    @Select("select id,doctor_id as doctorId,doctor_name as doctorName,doctor_age as doctorAge,doctor_gender as doctorGender,doctor_job as doctorJob from doctor where id=#{id}")
    Doctor selectOneDoctorById(String id);



    @Update("update doctor set doctor_age=#{doctorAge},doctor_gender=#{doctorGender},doctor_job=#{doctorJob} where id=#{id}")
    int updateDoctorById(Doctor doctor);



}
